﻿using MiniExcelLibs;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Synergy
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("007"))
            {
                Form fm = new FormCxbb();
                fm.Show();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
        }

        

        private void button2_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("003"))
            {
                Form fm = new FormWgbg();
                fm.Show();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
        }

        private void buttonRunCard_Click(object sender, EventArgs e)
        {
             if (pub.是否有权限("001"))
            {
            Form fm = new FormRunCard();
            fm.ShowDialog();
            }
             else
             {
                 MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
             }
        }

        private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void button1RunCard_Click(object sender, EventArgs e)
        {
             if (pub.是否有权限("002"))
            {
            Form fm = new FormHzRc();
            fm.ShowDialog();
            }
             else
             {
                 MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
             }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("004"))
            {
            Form fm = new FormZhijian();
            fm.ShowDialog();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("006"))
            {
                Form fm = new FormJiesuan();
                fm.ShowDialog();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("005"))
            {
            Form fm = new FormWgrk();
            fm.ShowDialog();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("008"))
            {
            Form fm = new Formqxpz();
            fm.ShowDialog();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
        }

        private void button7_Click(object sender, EventArgs e)
        {
           // if (pub.是否有权限("008"))
           // {
                //Form fm = new FormCLCK();
                //fm.ShowDialog();
          //  }
            //else
            //{
            //    MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            //}
        }

        private void button7_Click_1(object sender, EventArgs e)
        {
            if (pub.是否有权限("005"))
            {
                Form fm = new FormWGRK2();
                fm.ShowDialog();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
        }

        private void button打印图纸_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("003"))
            {
                Form fm = new Form打印图纸();
                fm.Show();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            this.Text += "-"+Application.ProductVersion;
        }

        private void button不良原因维护_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("011"))
            {
                Form fm = new Form不良原因维护();
                fm.Show();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
           
        }

        private void button8_Click(object sender, EventArgs e)
        {

            Form fm = new Form工序时间段报表();
            fm.Show();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("009"))
            {
                Form fm = new Form人员工序设置();
                fm.Show();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
           
        }

        private void button快递单号回写发货单_Click(object sender, EventArgs e)
        {
            if (pub.是否有权限("010"))
            {
                Form快递单号回写发货单 fm = new Form快递单号回写发货单();
                fm.Show();
            }
            else
            {
                MessageBox.Show("您未得到该授权", "提示", MessageBoxButtons.OK);
            }
            
        }

        private void button导出所有BOM_Click(object sender, EventArgs e)
        {
            //string sql = "select * from view_BOM查询 order by 母件编码";
            //DataTable dt = pub.U8GetTable(sql);
            ////选择保存路径
            //SaveFileDialog saveFileDialog = new SaveFileDialog();
            //saveFileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx";
            //saveFileDialog.FilterIndex = 1;
            //saveFileDialog.RestoreDirectory = true;
            //saveFileDialog.FileName =  "所有BOM"  + DateTime.Now.ToFileTime();
            //if (saveFileDialog.ShowDialog() == DialogResult.OK)
            //{
            //    string path = saveFileDialog.FileName;
            //    //导出
            //    MiniExcel.SaveAs(path, dt);
            //    MessageBox.Show("导出结束");
            //}

            Form导出BOM from = new Form导出BOM();
            from.ShowDialog();
        }
    }
}
